#pragma once
#include "../public/constants.hpp"
#include "../iterator/iterator_traits.hpp"
#include "../functor/functor_ease_dump.hpp"

#include <algorithm>

namespace bla {
	/*
	 * get iterator points to the max value
	 * para: InputItereator:class type, isLeftmaxFunctor(val1, val2): functor with two paras
	 * note: if end <= begin, the res is begin
	 */
	template <typename InputItereator, typename isLeftMaxFunctor>
	InputItereator max(InputItereator begin, InputItereator end, isLeftMaxFunctor functor) {
		InputItereator ret = begin;
		for (InputItereator loc = begin + 1; loc != end; ++loc) {
			if (functor(*loc, *ret)) ret = loc;
		}
		return ret;
	}

	/*
	 * get iterator points to the max value
	 * para: InputItereator:class type, isLeftmaxFunctor(val1, val2): functor with two paras
	 * note: if end <= begin, the res is begin
	 */
	template <typename InputItereator>
	InputItereator max(InputItereator begin, InputItereator end) {
		InputItereator ret = begin;
		for (InputItereator loc = begin + 1; loc != end; ++loc) {
			_isLeftMaxFunctor<InputItereator::_valueType> _func;
			if (_func(*loc, *ret)) ret = loc;
		}
		return ret;
	}
}

